﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace System.Security.Cryptography
{
    public static class MD5CryptoServiceProviderExtensions
    {
        public static byte[] ComputeFileHash(this MD5CryptoServiceProvider md5, string filename)
        {
            using (var fileStream = new FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite))
            {
                    return md5.ComputeHash(fileStream);
            }   
        }
    }
}
